{include file="public/header" /}

<link href="/static/admin/css/layui.css" rel="stylesheet">
<script type="text/javascript" src="/ckplayer/ckplayer.js" charset="UTF-8"></script>

<body class="gray-bg">
<div class="{if $ismobile==0}wrapper wrapper-content{/if} animated fadeInRight">
    
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5><span style="color:green">推广链接</span></h5>
        </div>
        <div class="ibox-title col-sm-5" style="border-width: 1px 0 0; float:left;">
            <div>
                <button class="btn btn-danger btn-xs multipleDelete" type="button" style="background-color: #18a689;border-color: #18a689;color:yellow">当前片库价格:{$moneypian}</button>
            </div>
            <div class="input-group col-sm-4" style="float:left;">
                <input id="number" type="number" class="form-control" name="qq" placeholder="请输入单价">
			</div>
			<div style="float:left;margin-left:5px;color:yellow">
			    <button class="btn btn-primary" id="allupdate"  type="button" style="color:yellow"> <i class="fa fa-save"></i> 修改视频价格</button>
			</div>
        </div>
        
        <div class="ibox-title col-sm-7" style="border-width: 1px 0 0;float:left;" >
            <div>
                <button class="btn btn-danger btn-xs multipleDelete" type="button" style="background-color: #18a689;border-color: #18a689;color:yellow">当前包天价格：{$b_money}（包天金额必须为30,38,39,48,58自动开通包天功能,价格修改为0时关闭包天功能）</button>
            </div>
            <div class="input-group col-sm-4" style="float:left;" id="txfeilv">
                <select class="form-control m-b chosen-select  " name="zftd" id="zftd">
                	<option value="0">0</option>
    			    <option value="30">30</option>
    			    <option value="38">38</option>
    			    <option value="39">39</option>
    			    <option value="48">48</option>
    			    <option value="58">58</option>
                </select>
            </div>
            <div style="float:left;margin-left:5px;">
                <button class="btn btn-primary" id="allupdatebaotian"  type="button" style="color:yellow"><i class="fa fa-save"></i> 修改包天价格</button>
            </div>
        </div>
    </div>
    
    
    
    <div class="ibox float-e-margins">
        <div class="ibox-title col-sm-12" style="border-width: 1px 0 0;float:left;" >
            <a href="/daili/tuiguang/add.html">
                <button class="btn btn-outline btn-primary" type="button" >添加推广链接</button>
                (温馨提示：<b style="color:red;">m3u8地址写0,首页推广无视频!</b>)
            </a>
            <table class="table table-hover" style="text-align:center;table-layout:fixed;" cellspacing="0" cellpadding="0">
                <thead>
                    <tr>
                       <td width="20">ID</td>
                        <td width="600" style="color:red;font-size:18px">因为大家推广方式不同,有多种链接供大家推广,可以自己推广看看红不红,选择适合自己的链接进行推广<br/><span style="color:green">(红的厉害的,可以提取标"(新)"的链接推广)</span></td>
                        <td width="200">操作</td>
                    </tr>
                </thead>
                <tbody>
                    <script id="list-template" type="text/html">
                    {{# for(var i=0;i<d.length;i++){  }}
                    <tr>
                        <td width="20">{{d[i].id}}</td>
                        <td id="short_link_0" style="word-wrap: break-word;word-break: break-all;overflow: hidden;">
                            <div style="color:red">推广链接</div>
                            <input id="co_0" type="text" value="{{d[i].kdwz1}}" onfocus="this.select();">
                            <a href="https://api.ip138.com/qrcode/?text={{d[i].kdwz1}}&token=1e0e7bb426d15eedd19b22bda21fbf1e" target="_blank">点击生成二维码</a>
                            <div style="color:red"><span style="color:green">(新)</span>第一种短链接</div>
                            <input id="co_0" type="text" value="{{d[i].gmldwz8}}" onfocus="this.select();">
                            <a href="https://api.ip138.com/qrcode/?text={{d[i].gmldwz8}}&token=1e0e7bb426d15eedd19b22bda21fbf1e" target="_blank">点击生成二维码</a>
                            <div style="color:red"><span style="color:green">(新)</span>第二种短链接</div>
                            <input id="co_0" type="text" value="{{d[i].linkdwz7}}" onfocus="this.select();">
                            <a href="https://api.ip138.com/qrcode/?text={{d[i].linkdwz7}}&token=1e0e7bb426d15eedd19b22bda21fbf1e" target="_blank">点击生成二维码</a>
                            <div style="color:red">第三种短链接</div>
                            <input id="co_0" type="text" value="{{d[i].ldwz6}}" onfocus="this.select();">
                            <a href="https://api.ip138.com/qrcode/?text={{d[i].ldwz6}}&token=1e0e7bb426d15eedd19b22bda21fbf1e" target="_blank">点击生成二维码</a>
                            <div style="color:red">第四种短链接</div>
                            <input id="co_0" type="text" value="{{d[i].ddwz3}}" onfocus="this.select();">
                            <a href="https://api.ip138.com/qrcode/?text={{d[i].ddwz3}}&token=1e0e7bb426d15eedd19b22bda21fbf1e" target="_blank">点击生成二维码</a>
                            <div style="color:red">第五种短链接</div>
                            <input id="co_0" type="text" value="{{d[i].ydwz4}}" onfocus="this.select();">
                            <a href="https://api.ip138.com/qrcode/?text={{d[i].ydwz4}}&token=1e0e7bb426d15eedd19b22bda21fbf1e" target="_blank">点击生成二维码</a>
                        </td>
                        <td width="200">
                            <a href="/daili/tuiguang/edit?id={{d[i].id}}" class="btn btn-primary btn-outline btn-xs" title="编辑" ><i class="fa fa-paste"></i> 编辑</a>
                            <a href="javascript:;" onclick="del_dwz({{d[i].id}})" class="btn btn-danger btn-outline btn-xs" title="删除"  ><i class="fa fa-trash-o"></i>删除</a>
                        </td>
                    </tr>
                    {{# } }}
                    </script>
                </tbody>
                <tbody id="list-content"></tbody>
            </table>  
            <div class="social-share1" style="text-align:center; display:none;" id="shareDiv">
                <a class="layui-layer-ico layui-layer-close layui-layer-close1" href="javascript:;">
                    <img src="/static/index/3wem.png" data-id="0">
                </a>
            <img id="testimg" style="float:right;cursor:pointer" alt="" width="300" height="300"/>
            </div> 
            <div id="AjaxPage" style=" text-align: right;"></div>
            <div id="allpage" style=" text-align: right;"></div>
        </div>
    </div>
{include file="public/footer" /}
<script src="__JS__/clipboard.min.js"></script>
<script type="text/javascript">

// function moban(id){
	
// 	window.location="{:url('siyou/moban')}"+"?id="+id;

// }

// function dwz(id){
    
//      var id = id;
     
//      if(id > 0){
//          type = "youzan";
//      }else{
//          type = "";
//      }
     
//      var  typed = "typed";
   

//      $.getJSON('{:url("Tuiguang/index")}', {id: id,typed:typed ,type:type}, function(data){
//             var str2 = '';
//             str = data.url;
//             str3 = str.substring(0, 7);
//             if (str3 == 'http://') {
//                 str2 = 'http://';
//                 str = str.substring(7, str.length);
//             }
//             for (i = 0; i < str.length; i++) {
//                 if (str.charCodeAt(i) == '47') str2 += '/';
//                 else if (str.charCodeAt(i) == '63') str2 += '?';
//                 else if (str.charCodeAt(i) == '38') str2 += '&';
//                 else if (str.charCodeAt(i) == '61') str2 += '=';
//                 else if (str.charCodeAt(i) == '58') str2 += ':';
//                 else str2 += '%' + str.charCodeAt(i).toString(16);
//             }
//           var str4 = 'https://open.weixin.qq.com/' + str2; 
          
//           updwz(str4,data.ddh,data.userid);
//           if (data.url != '') {
//                 layer.prompt({
//                     formType: 0,
//                     value: str4,
//                     title: '我的分享链接',
//                     shadeClose: true,
//                     btn: ['复制链接', '关闭'],
//                     end: function () { //最后执行reload
//                         location.reload();
//                     }
//                 }, function(value, index, elem){
//                     elem.focus()
//                     elem.select()
//                     top.document.execCommand('Copy')&&(layer.close(index),layer.msg('复制成功', {time: 1000}))
//                 })
//             } else {
//                 error("请等候10秒哟")
//             }
            
            
            
            
//         });

// }




// 	function hub(id){
    
//      var id = id;
//      $.getJSON('{:url("Tuiguang/hub")}', {id: id}, function(data){

//           if (data.url != '') {
//                     layer.prompt({
//                         formType: 0,
//                         value: data.url,
//                         title: '我的分享链接',
//                         shadeClose: true,
//                         btn: ['复制链接', '关闭']
//                     }, function(value, index, elem){
//                         elem.focus()
//                         elem.select()
//                         top.document.execCommand('Copy')&&(layer.close(index),layer.msg('复制成功', {time: 1000}))
//                     })
//                 } else {
//                     error("请等候10秒哟")
//               }
//         });

// }


//   $(document).on('change', '.price', function(event) {
// 		event.preventDefault();
// 		var id = $(this).attr('data-id'),
// 		price = $(this).val();
// 		$.ajax({
// 		type : "post",
// 		url : "{:url('editprice')}",
// 		dataType: "json",  
// 		async: true,
// 		data: {id: id, money : price, cz : 'jiage'},
// 		timeout: 10000 ,
// 		success : function(data){
// 		if(data.zt=='1'){  
		
// 		layer.msg("设置成功",{icon:1,time:1500,shade: 0.1});
// 		} 
// 		},
// 		error:function(){
// 		}
// 		});
// 	});
	
// 	$(document).on('change', '.title', function(event) {
// 		event.preventDefault();
// 		var id  = $(this).attr('data-id'),
// 		title  = $(this).val();
// 		//更新标题
// 		$.ajax({
// 		type : "post",
// 		url : "{:url('edittitle')}",
// 		dataType: "json",  
// 		async: true,
// 		data: {id: id, name : title, cz : 'name'},
// 		timeout: 10000 ,
// 		success : function(data){
// 		if(data.zt=='1'){  
// 		layer.msg("设置成功",{icon:1,time:1500,shade: 0.1});
// 		} 
// 		},
// 		error:function(){
// 		}
// 		});
// 	});
	
// 	var changeContent = function() {
// 	var links = $('input[name="ids[]"]:checked');
// 	var myDate=new Date();
// 	var contents = "{$Think.config.tsybt} \r\n 今日推荐视频更新于 {:date('Y-m-d')}  \r\n------------------------ \r\n";
// 	$.each(links, function(index, val) {
// 	contents += $(val).attr('data-title') + "\r\n" + $(val).attr('data-url') + "\r\n\r\n";
// 	});
// 	contents += " \r\n------------------------ \r\n  {$Think.config.tsyzbts} \r\n ++++ {$Think.config.tsyjwts} ++++";
// 	$('#clip-content').val(contents);
// 	var clipboard = new Clipboard('.get-links');
// 	clipboard.on('success', function(e) {
	
// 	layer.msg('推广链接已经成功复制到您的黏贴板');
// 	});
// 	clipboard.on('error', function(e) {
	
// 	layer.msg('复制失败 请手动复制');
// 	});
// 	}
	
// 	$(document).on('click', '.chk-all', function(event) {
// 	event.preventDefault();
// 	$('input[name="ids[]"]').prop('checked', 'checked');
// 	changeContent();
// 	});



// 	$(document).on('click', '.unchk-all', function(event) {
// 	event.preventDefault();
// 	$('input[name="ids[]"]').prop('checked', false);
// 	changeContent();
// 	});
// 	$(document).on('change', 'input[name="ids[]"]', function(event) {
// 	event.preventDefault();
// 	changeContent();
// 	});
	
	
	
	
  

  

function edit_siyou(id){
    location.href = './edit/id/'+id+'.html';
}


function del_siyou(id){
    dashang.confirm(id,'{:url("del")}');
}

function del_dwz(id){
    dashang.confirm(id,'{:url("del_dwz")}');
}


	//全部删除
		$("#alldel").click(function () {
			layer.confirm('确认删除全部？', function (index) {
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('index')}",
					data:{alldel:'alldel'},
					success: function (data) {
						if (data.code == "1") {
							layer.msg(data.msg, {
								icon: 1,
								time: 1000,
							}, function () {
								location.reload();
							});
						} else {
							layer.msg(data.msg, {
								icon: 2,
								time: 2000,
							}, function () {
							});
						}
					},
					error: function (data) {
						layer.msg(data.msg, {
							icon: 2,
							time: 3000 //2秒关闭
						}, function () {
						});
					}
				})
			});
		});


		//全部改价
		$("#allupdate").click(function () {
			var number = $("#number").val();
			var sj = $("#number").val();
			
			if (!number||!sj) {
				alert("不能为空");
			}
			layer.confirm('确认修改片库价格吗？', function (index) {
				$.ajax({
					type: 'POST',
					dataType: 'json',
					url: "{:url('index')}",
					data:{number:number,allupdate:'allupdate',sj:sj},
					success: function (data) {
						if (data.code == "1") {
							layer.msg(data.msg, {
								icon: 1,
								time: 1000,
							}, function () {
								location.reload();
							});
						} else {
							layer.msg(data.msg, {
								icon: 2,
								time: 2000,
							}, function () {
							});
						}
					},
					error: function (data) {
						layer.msg(data.msg, {
							icon: 2,
							time: 3000 //2秒关闭
						}, function () {
						});
					}
				})
			});
		});
		
		
		  //全部改价
		$("#allupdatebaotian").click(function () {
		 
			var number = $("#baotian").val();
		    var money_type = $("#txfeilv option:selected").val();
			layer.confirm('确认修改包天价格吗？', function (index) {
				$.ajax({
					type: 'POST',
					dataType: 'json',
					url: "{:url('index')}",
					data:{number:number,allupdate:'allupdatebaotian',money_type:money_type},
					success: function (data) {
						if (data.code == "1") {
							layer.msg(data.msg, {
								icon: 1,
								time: 1000,
							}, function () {
								location.reload();
							});
						} else {
							layer.msg(data.msg, {
								icon: 2,
								time: 2000,
							}, function () {
							});
						}
					},
					error: function (data) {
						layer.msg(data.msg, {
							icon: 2,
							time: 3000 //2秒关闭
						}, function () {
						});
					}
				})
			});
		});



function All(e, itemName){
	var aa = document.getElementsByName(itemName);
	for (var i=0; i<aa.length; i++)
	aa[i].checked = e.checked; 
	}
	function checkdel(delid,formname){
	var flag = false;
	for(i=0;i<delid.length;i++){
	if(delid[i].checked == true){
	flag = true;
	break;
	}
	}
	if(!flag){
	return true;
	}else{
	formname.submit();
	}
}




{if $ismobile==1}
function read(id){
	location="{:url('siyou/read')}"+"?id="+id;

}
{/if}
</script>
<script type="text/javascript">
    //laypage分页
    Ajaxpage();
    function Ajaxpage(curr){
       
        $.getJSON('{:url("index")}', {page: curr || 1}, function(data){
            $(".spiner-example").css('display','none'); //数据加载完关闭动画 
            if(data==''){
                $("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
            }else{
                var re = 0;
                for (var j=0;j<data.length;j++)
                { 
                  
                    if(data[j]['upstate'] == 0 ){
                            re = 1;
                            var str =data[j]['dwz1'];
                            // alert(str);
                            var str2 = '';
                            var str3 = str.substring(0, 7);
                            if (str3 == 'http://') {
                                str2 = 'http://';
                                str = str.substring(7, str.length);
                            }
                            for (i = 0; i < str.length; i++) {
                                if (str.charCodeAt(i) == '47') str2 += '/';
                                else if (str.charCodeAt(i) == '63') str2 += '?';
                                else if (str.charCodeAt(i) == '38') str2 += '&';
                                else if (str.charCodeAt(i) == '61') str2 += '=';
                                else if (str.charCodeAt(i) == '58') str2 += ':';
                                else str2 += '%' + str.charCodeAt(i).toString(16);
                            }
                          
                           str4 = "https://open.weixin.qq.com/"; 
                           str4 = str4 + str2;
                          
                            $.getJSON('{:url("editprice")}', {str4:str4,ddh:data[j]['ddh'],userid:data[j]['userid']}, function(data){
                       
                            });
                          
                         
                        //   updwz(str4,data[j]['ddh'],data[j]['userid']);
                    }
                        
                }
                
                if(re == 1){
                   location.reload();  
                }
               
              
                var tpl = document.getElementById('list-template').innerHTML;
                laytpl(tpl).render(data, function(html){
                    document.getElementById('list-content').innerHTML = html;
                });
                laypage({
                    cont: $('#AjaxPage'),//容器。值支持id名、原生dom对象，jquery对象,
                    pages:'{$allpage}',//总页数
                    skip: true,//是否开启跳页
                    skin: '#1AB5B7',//分页组件颜色
                    curr: curr || 1,
                    groups: 3,//连续显示分页数
                    jump: function(obj, first){
                        if(!first){
                            Ajaxpage(obj.curr)
                        }
                     $('#allpage').html('第'+ obj.curr +'页，共'+ obj.pages +'页');
                    }
                });
            }
        });
    }
    
function updwz(str4,ddh,userid){
    var str4 = str4;
    var ddh  = ddh;
    var userid  = userid;
    console.log(str4);
     $.getJSON('{:url("editprice")}', {str4:str4,ddh:ddh,userid:userid}, function(data){
                       
    });
}

</script>
</body>
</html>